import get from '@dfeidao/atom-web/local/get';
import set from '@dfeidao/atom-web/local/set';
import fire from '@dfeidao/atom-web/msg/fire';
import error from '@dfeidao/atom-web/msgbox/error';
import { IFeidaoAiBrowserComponent } from '@dfeidao/web/interfaces';

interface Aa {
	p_id: string;
	flag: number;
	client_point_id: string;
	client_style: string;
}

export default async function a001(fd: IFeidaoAiBrowserComponent) {
	const flag = get(fd, 'flag');

	let curr_dept = get(fd, 'curr_dept') as Aa;


	if (flag !== 0) {
		if (!curr_dept) {
			error('请先选中一条数据');
			return;
		}
	} else {
		curr_dept = {} as Aa;
		curr_dept.p_id = '';
		set(fd, 'curr_dept', curr_dept);
	}






	curr_dept.flag = 1;// 新增同级
	const client_point_id: string = get(fd, 'client_point_id');
	const client_style: string = get(fd, 'client_style');

	curr_dept.client_point_id = client_point_id;
	curr_dept.client_style = client_style;

	set(fd, 'curr_dept', curr_dept);
	fire('zj-000002', 'ec001', get(fd, 'curr_dept'));
	// console.log(curr_dept);
	// remove(fd, 'curr_dept');
}
